﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using QUANLYCHAMCONG.BL.Entities;
using Hopthoai;
using QUANLYCHAMCONG.BL.BUS;
using DgvFilterPopup;
using Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
using Microsoft.VisualBasic.CompilerServices;
using System.Reflection;

namespace QUANLYCHAMCONG.PL.CMS.Nhanvien
{
    public partial class Nhanvien : UserControl
    {
        public delegate void _Close();
        public event _Close Close;
        STAFF nv;
        int flag = 0;
        frmHoidap f;
        public Total UcStatusRoom { get; set; }
        public void ReloadStattus()
        {
            Thongke tk = new Thongke();
            this.UcStatusRoom.DtData = BAOCAOBUS.ThongkeTotal(tk);
            this.UcStatusRoom.Settext();
        }
        public Nhanvien()
        {
            InitializeComponent();
        }
        public void Event()
        {
            this.toolbar1.Add += new Toolbar._Add(toolbar1_Add);
            this.toolbar1.Edit += new Toolbar._Edit(toolbar1_Edit);
            this.toolbar1.Delete += new Toolbar._Delete(toolbar1_Delete);
            this.toolbar1.Save += new Toolbar._Save(toolbar1_Save);
            this.toolbar1.Refresh += new Toolbar._Refesh(toolbar1_Refresh);
            LoadData();
            InitGrid();
        }

        void toolbar1_Refresh()
        {
            RemoveCheckbox();
            this.toolbar1.SetSave();
            this.flag = 0;
            this.dgvdanhsachnhanvien.ReadOnly = true;
            this.dgvdanhsachnhanvien.AllowUserToAddRows = true;
            LoadData();
        }
      
        void toolbar1_Save()
        {
            try
            {
                if (flag == 2)
                {
                    Common.Flag = this.flag;
                    DataGridViewRow current =this.dgvdanhsachnhanvien.CurrentRow;
                    Common.MaNV = current.Cells["MANV"].Value.ToString();
                    frmnhanvien f = new frmnhanvien();
                    f.Reload += new frmnhanvien._Reload(fm_Reload);
                    f.ShowDialog();
                }
                if (flag == 3)
                {
                    f = new frmHoidap("bạn có chắc chắn muốn xóa nhưng nhân viên vừa chọn không?",frmHoidap.CO.hien,frmHoidap.KHONG.hien,frmHoidap.THOAT.an,frmHoidap.HINH.canhbao);
                    if (f.ShowDialog() == DialogResult.Yes)
                    {
                        foreach (DataGridViewRow dr in this.dgvdanhsachnhanvien.Rows)
                        {
                            try
                            {
                                if (dr.Cells[0].Value != null)
                                {
                                    nv = new STAFF();
                                    nv.MANV = dr.Cells["MANV"].Value.ToString();
                                    STAFFBUS.Delete(nv);
                                }
                            }
                            catch
                            {
                                f = new frmHoidap("Bạn chưa chọn nhân viên nào!", frmHoidap.CO.an, frmHoidap.KHONG.an, frmHoidap.THOAT.an, frmHoidap.HINH.thongtin);
                                f.ShowDialog();
                            }
                        }
                        f = new frmHoidap("Xóa thành công nhân viên!", frmHoidap.CO.an, frmHoidap.KHONG.an, frmHoidap.THOAT.an, frmHoidap.HINH.thongtin);
                        f.ShowDialog();
                        RemoveCheckbox();
                        this.toolbar1.SetSave();
                        this.dgvdanhsachnhanvien.ReadOnly = true;
                        this.dgvdanhsachnhanvien.AllowUserToAddRows = true;
                    }
                    else
                    {
                        this.toolbar1.SetSave();
                        RemoveCheckbox();
                        this.flag = 0;
                    }
                }
            }
                catch{}

        }
        private int FindAviable()
        {
            foreach (DataGridViewColumn dr in this.dgvdanhsachnhanvien.Columns)
            {
                if (dr is DataGridViewCheckBoxColumn)
                    return 1;
            }
            return 0;
        }
        private void RemoveCheckbox()
        {
            if (FindAviable() == 1)
            {
                this.dgvdanhsachnhanvien.Columns.RemoveAt(0);
                this.dgvdanhsachnhanvien.Controls.RemoveByKey(((System.Windows.Forms.CheckBox)this.dgvdanhsachnhanvien.Controls.Find("checkboxHeader", true)[0]).Name);
                LoadData();
            }
        }
        private void AddCheckbox(System.Data.DataTable dt)
        {
            if (FindAviable() == 0)
            {
                DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn();
                cb.Width = 30;
                cb.FillWeight = 30;
                cb.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                this.dgvdanhsachnhanvien.Columns.Insert(0, cb);
                System.Drawing.Rectangle rect = this.dgvdanhsachnhanvien.GetCellDisplayRectangle(0, -1, true);
                rect.X = rect.Location.X + cb.Width / 10;
                System.Windows.Forms.CheckBox checkboxHeader = new System.Windows.Forms.CheckBox();
                checkboxHeader.Name = "checkboxHeader";
                checkboxHeader.Size = new Size(18, 18);
                checkboxHeader.Location = rect.Location;
                checkboxHeader.CheckedChanged += new EventHandler(checkboxHeader_CheckedChanged);
                this.dgvdanhsachnhanvien.Controls.Add(checkboxHeader);
                this.dgvdanhsachnhanvien.Columns[0].Width = 50;
                this.dgvdanhsachnhanvien.DataSource = dt;
            }
        }
        void checkboxHeader_CheckedChanged(object sender, EventArgs e)
        {
            if (((System.Windows.Forms.CheckBox)this.dgvdanhsachnhanvien.Controls.Find("checkboxHeader", true)[0]).Checked == true)
            {
                for (int i = 0; i < this.dgvdanhsachnhanvien.RowCount; i++)
                {
                    this.dgvdanhsachnhanvien[0, i].Value = ((System.Windows.Forms.CheckBox)this.dgvdanhsachnhanvien.Controls.Find("checkboxHeader", true)[0]).Checked;
                }
            }
            else
            {
                for (int i = 0; i < this.dgvdanhsachnhanvien.RowCount; i++)
                {
                    this.dgvdanhsachnhanvien[0, i].Value = false;
                }
            }
        }
        public void LoadData()
        {
            try
            {
                nv = new STAFF();
                this.dgvdanhsachnhanvien.DataSource = STAFFBUS.SelectAll();
               // Common.HightLightDataGridViewRow(ref this.dgvdanhsachnhanvien, STAFFBUS.SelectAll());
                this.dgvdanhsachnhanvien.Columns["MANV"].FillWeight = 100;
            }
            catch { }
        }
        public void HideColumn()
        {
            this.dgvdanhsachnhanvien.Columns["ANH"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["THEDOAN"].Visible = false;
             this.dgvdanhsachnhanvien.Columns["NOISINHHOAT"].Visible = false;
             this.dgvdanhsachnhanvien.Columns["NGAYVAODOAN"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["NGAYVAODANG"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["THEDANG"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["NOISINHHOATDANG"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["GHICHU"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["NGAYBD"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["MACTY"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["MABC"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["MANN"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["DIACHI"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["MACCM"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["SONGAYPHEP"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["SODT"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["SOCMND"].Visible = false;
            this.dgvdanhsachnhanvien.Columns["EMAIL"].Visible = false;

        }
        private void InitGrid()
        {
            DgvFilterManager f = new DgvFilterManager();
            f.ColumnFilterAdding += new ColumnFilterEventHandler(f_ColumnFilterAdding);
            f.DataGridView = (DataGridView)this.dgvdanhsachnhanvien;
        }
        void f_ColumnFilterAdding(object sender, ColumnFilterEventArgs e)
        {
            switch (e.Column.Name)
            {
                case "GIOITINH":
                case "HONNHAN":
                case "TENPB":
                case "TENCV":
                    e.ColumnFilter = new DgvComboBoxColumnFilter();
                    break;
            }
        }
        public void TasStartExcel([Optional, DefaultParameterValue("Sheet1")] string SheetName)
        {
            try
            {
                ExApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
                TasWBook = ExApp.Workbooks.Add(Missing.Value);
                TasWSheet = (Microsoft.Office.Interop.Excel.Worksheet)ExApp.Worksheets["Sheet1"];
                TasWSheet.Name = SheetName;
                ExApp.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        void SetActive()
        {
            this.toolbar1.SetToolBar(true, true, true, false, true, false, false, true);
        }
        void toolbar1_Delete()
        {
            this.flag = 3;
            Common.Flag = this.flag;
            this.dgvdanhsachnhanvien.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dgvdanhsachnhanvien.Rows[0].Selected = true;
            this.dgvdanhsachnhanvien.ReadOnly = false;
            this.dgvdanhsachnhanvien.AllowUserToAddRows = false;
            this.toolbar1.SetAdd_Edit_Delete();
            AddCheckbox(STAFFBUS.SelectAll());
        }
        void toolbar1_Edit()
        {
            this.toolbar1.EditName(null, null, null, "Xem", null, null, null, null);
            this.flag = 2;
            Common.Flag = this.flag;
            Common.MaNV = "";
            this.dgvdanhsachnhanvien.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dgvdanhsachnhanvien.Rows[0].Selected = true;
            this.dgvdanhsachnhanvien.ReadOnly = false;
            this.dgvdanhsachnhanvien.AllowUserToAddRows = false;
            this.toolbar1.SetAdd_Edit_Delete();
        }
        void toolbar1_Add()
        {
            flag = 1;
            frmnhanvien fm = new frmnhanvien();
            fm.UcStatusRoom = this.UcStatusRoom;
            fm.Reload += new frmnhanvien._Reload(fm_Reload);
            Common.Flag = this.flag;
            fm.ShowDialog();
        }
        void fm_Reload()
        {
            LoadData();
        }
        private void Nhanvien_Load(object sender, EventArgs e)
        {
           
            Event();
            SetLink();
            this.toolbar1.EditName(null, null, null, null, null, null, "Refesh", null);
            SetActive();
            
        }
        private void SetLink()
        {
            this.links1.SetValues("Nhân viên", "Danh sách nhân viên");
        }
        public System.Drawing.Point DoPhanGiaiManhinh()
        {
            System.Drawing.Point p = new System.Drawing.Point();
            Size s = SystemInformation.WorkingArea.Size;
            p.X = Size.Width / 2;
            p.Y = Size.Height / 2;
            return p;
        }
        System.Data.DataTable dt = new System.Data.DataTable();
        public static Microsoft.Office.Interop.Excel.Application ExApp;
        public static Microsoft.Office.Interop.Excel.Workbook TasWBook;
        public static Microsoft.Office.Interop.Excel.Worksheet TasWSheet = new Microsoft.Office.Interop.Excel.Worksheet();
        private void toolbar1_Excel()
        {
            
            System.Data.DataTable danhsachnv = new System.Data.DataTable();
            danhsachnv = STAFFBUS.PrintStaff();
            // xuat danh sach nhan vien 
             TasStartExcel("DANHSACHNHANVIEN");
             int count = danhsachnv.Rows.Count;
            // doc do phan giai man hinh
            frmwaiting f = new frmwaiting();
            f.Show();
            f.lbgoi.Text = "Đang duyệt...";
            f.lbphantram.Visible = true;
            f.tocdo.Visible = true;
            f.tocdo.Maximum = count;
            f.Location = DoPhanGiaiManhinh();
            f.Activate();
            int i = 0;
            int j = 0;
            System.Windows.Forms.Application.DoEvents();
            if (count != 0)
            {
                try
                {
                    Microsoft.Office.Interop.Excel.Worksheet tasWSheet = TasWSheet;
                    CreateHeaderNhanvien(1);
                    foreach(DataRow dr in danhsachnv.Rows)
                    {
                        f.tocdo.Value = i;
                        f.lbphantram.Text = Conversions.ToString((double)(Math.Round((double)(((double)i) / ((double)count)), 2) * 100.0)) + "%";
                        f.Activate();
                        System.Windows.Forms.Application.DoEvents();
                        //bat dau in 
                        tasWSheet.get_Range("A" + Conversions.ToString(j + 6) + ":O" + Conversions.ToString((int)(j + 6)), Missing.Value).Borders[XlBordersIndex.xlEdgeLeft].LineStyle = 1;
                        tasWSheet.get_Range("A" + Conversions.ToString(j + 6) + ":O" + Conversions.ToString((int)(j + 6)), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("A" + Conversions.ToString(j + 6) + ":O" + Conversions.ToString((int)(j + 6)), Missing.Value).Borders[XlBordersIndex.xlEdgeBottom].LineStyle = 3;
                        tasWSheet.get_Range("A" + Conversions.ToString(j+6), Missing.Value).set_Value(Missing.Value, (i + 1).ToString());
                        tasWSheet.get_Range("A" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("A" + Conversions.ToString(j + 6), Missing.Value).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                        tasWSheet.get_Range("A" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + (i + 1).ToString());
                        tasWSheet.get_Range("B" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["MANV"].ToString());
                        tasWSheet.get_Range("B" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("C" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["TENNV"].ToString());
                        tasWSheet.get_Range("C" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("D" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" +  dr["GIOITINH"].ToString());
                        tasWSheet.get_Range("D" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        DateTime ngay =Convert.ToDateTime(dr["NGAYSINH"].ToString());
                        tasWSheet.get_Range("E" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + ngay.Date.ToShortDateString());
                        tasWSheet.get_Range("E" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("F" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["HONNHAN"].ToString());
                        tasWSheet.get_Range("F" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("G" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["TENPB"].ToString());
                        tasWSheet.get_Range("G" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("H" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["TENCV"].ToString());
                        tasWSheet.get_Range("H" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("I" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["TENNN"].ToString());
                        tasWSheet.get_Range("I" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        tasWSheet.get_Range("J" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["TENBC"].ToString());
                        tasWSheet.get_Range("J" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        //so cmnv 
                        tasWSheet.get_Range("K" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["SOCMND"].ToString());
                        tasWSheet.get_Range("K" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        //dia chi
                        tasWSheet.get_Range("L" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["DIACHI"].ToString());
                        tasWSheet.get_Range("L" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        //Email
                        tasWSheet.get_Range("M" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["EMAIL"].ToString());
                        tasWSheet.get_Range("M" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        //so dien thoai 
                        tasWSheet.get_Range("N" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value, "'" + dr["SODT"].ToString());
                        tasWSheet.get_Range("N" + Conversions.ToString(j + 6), Missing.Value).Borders[XlBordersIndex.xlEdgeRight].LineStyle = 1;
                        //ngay vao lam 
                        DateTime ngayvaolam =Convert.ToDateTime(dr["NGAYBD"].ToString());
                        tasWSheet.get_Range("O" + Conversions.ToString(j + 6), Missing.Value).set_Value(Missing.Value,  "'" +ngayvaolam.ToShortDateString() );
                        i++;
                        j++;
                    }
                    tasWSheet.get_Range("A" + Conversions.ToString(j + 6) + ":O" + Conversions.ToString((int)(j + 10)), Missing.Value).Borders[XlBordersIndex.xlEdgeTop].LineStyle = 1;
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Lỗi :" + ex.Message.ToString());
                    f.Close();
                }
                finally
                {
                    f.Close();
                }
            }
            else
            {
                frmHoidap hoi = new frmHoidap("Dữ liệu trống!", frmHoidap.CO.an, frmHoidap.KHONG.an, frmHoidap.THOAT.an, frmHoidap.HINH.baoloi);
                hoi.ShowDialog();
                f.Close();
            }

        }
        void CreateHeaderNhanvien(int StartRow)
        {
            int num2 = StartRow + 3;
            Worksheet tasWSheet = TasWSheet;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 - 3)) + ":O" + Conversions.ToString((int)(num2 - 3)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 - 3)), Missing.Value).set_Value(Missing.Value, "Danh sách nhân viên");
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 - 3)), Missing.Value).Font.Bold = true;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 - 3)), Missing.Value).Font.Size = 20;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2-3)), Missing.Value).HorizontalAlignment = XlHAlign.xlHAlignCenter;
            tasWSheet.get_Range("A" + Conversions.ToString(num2) + ":A" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("A" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "STT");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["A", Missing.Value], null, "ColumnWidth", new object[] { 3.2 }, null, null, false, true);
            tasWSheet.get_Range("B" + Conversions.ToString(num2) + ":B" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("B" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Mã nhân viên");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["B", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("C" + Conversions.ToString(num2) + ":C" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("C" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Tên nhân viên");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["C", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("D" + Conversions.ToString(num2) + ":D" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("D" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Giới tính");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["D", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("E" + Conversions.ToString(num2) + ":E" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("E" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Ngày sinh");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["E", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("F" + Conversions.ToString(num2) + ":F" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("F" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Tình trạng hôn nhân");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["F", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("G" + Conversions.ToString(num2) + ":G" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("G" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Phòng ban");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["G", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("H" + Conversions.ToString(num2) + ":H" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("H" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Chức vụ");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["H", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("I" + Conversions.ToString(num2) + ":I" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("I" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Nghề nghiệp");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["I", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("J" + Conversions.ToString(num2) + ":J" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("J" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Trình độ");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["J", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("K" + Conversions.ToString(num2) + ":K" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("K" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "CMND");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["K", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("L" + Conversions.ToString(num2) + ":L" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("L" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Địa chỉ");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["L", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("M" + Conversions.ToString(num2) + ":M" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("M" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Email");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["M", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("N" + Conversions.ToString(num2) + ":N" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("N" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Số điện thoại");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["N", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("O" + Conversions.ToString(num2) + ":O" + Conversions.ToString((int)(num2 + 1)), Missing.Value).Merge(Missing.Value);
            tasWSheet.get_Range("O" + Conversions.ToString(num2), Missing.Value).set_Value(Missing.Value, "Ngày vào làm");
            NewLateBinding.LateSetComplex(tasWSheet.Columns["O", Missing.Value], null, "ColumnWidth", new object[] { 14 }, null, null, false, true);
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 )) + ":O" + Conversions.ToString(num2+1), Missing.Value).Font.Bold = true;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2)) + ":O" + Conversions.ToString(num2+1), Missing.Value).Font.Size = 10;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 )) + ":O" + Conversions.ToString(num2+1), Missing.Value).HorizontalAlignment = XlHAlign.xlHAlignCenter;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2)) + ":O" + Conversions.ToString(num2+1), Missing.Value).WrapText = 1;
            tasWSheet.get_Range("A" + Conversions.ToString((int)(num2 )) + ":O" + Conversions.ToString(num2+1), Missing.Value).Borders.LineStyle = 1;
            NewLateBinding.LateSetComplex(tasWSheet.Rows["3:3", Missing.Value], null, "RowHeight", new object[] { 30 }, null, null, false, true);
            tasWSheet = null;

        }
        private void toolbar1_Close()
        {
            if (this.Close != null)
                this.Close();
        }
    }
}
